package Coding.Th;

public class Sleep3 {
    public static void main(String[] args) {


        Thread t1 = new Thread("rose") {

            @Override
            public void run() {
                for (int i = 0; i < 5; i++) {

                    System.out.println(getName() + "let me go");

                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                    System.out.println("救我呢");
                    System.out.println("噗通");
                }


            }
        };


        Thread t2 = new Thread("Jack") {
            @Override
            public void run() {
                while (true){
                    System.out.println("you jump , I jump");

                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };

        t1.start();
        //将t2线程设置成守护线程,当进程结束,t2也会销毁 独立于主线程之外 的
        t2.setDaemon(true);
        t2.start();

    }
}
